<template>
  <div>
    <!-- 搜索 -->
    <!-- 技术报告录入 - Vin查询 -->
    <TopFilter :list="topFilterInit" :cols="3" :collapse="collapse" labelWidth="90" @filterChange="changeHandle"></TopFilter>
    <!-- table -->
    <FilterTable height="auto" selectionType="single" ref="table" :columns="columns" :params="fetchParams" :fetchapi="fetchapi"  :datakey="'records'" :onColumnsChange="columns => (this.columns = columns)" :onRowSelectChange="selectChange"> </FilterTable>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <multiuse-button @click="closeDrawer(1)">关 闭</multiuse-button>
      <multiuse-button @click="closeDrawer(2)" type="primary">保 存</multiuse-button>
    </div>
  </div>
</template>
<script>
// // import res from '@/mock/tableData';
import { getCarList} from '@/api/claim/factory/SpeCarNonFirstPartTypeWarrantyMaintain';
export default {
  // mixins: [dictionary],
  data() {
    return {
      fetchapi:getCarList,
      dataList: [],
      visible: false,
      visibleDrawer: false,
      collapse: false,
      infoId: null,
      topFilterInit: this.topFilterInitFun(),
      flterValue: {}, //参数
      columns: this.creatHeader(),
      // fetchApi: getUser,
      fetchParams: {}, //ipa 接口
      selectedRows: [] //选中经销商
    };
  },
  created() {
    // // this.dataList = [...res.data.items];
    // console.log(this.dataList);
  },
  methods: {
    //搜索数据
    topFilterInitFun() {
      return [
        { type: 'INPUT', label: 'VIN', fieldName: 'vin', placeholder: '请输入', initialValue: '' },
        { type: 'RANGE_DATE', label: '生产日期', fieldName: 'startTime|endTime', placeholder: '请输入', initialValue: '' },
      ];
    },
    //搜索获取数据
    changeHandle(val) {
      console.log(val);
      this.fetchParams = Object.assign({}, this.fetchParams, val);
      console.log(val);
    },
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: 'VIN', dataIndex: 'vin', sorter: true },
        { title: '车辆状态', dataIndex: 'status', sorter: true },
        { title: '车型', dataIndex: 'modelCode', sorter: true },
        { title: 'modelName', dataIndex: 'modelName', hidden: true, sorter: true },
        { title: '销售经销商', dataIndex: 'dealerName', sorter: true },
        { title: '生产日期', dataIndex: 'prodDate', sorter: true },
        { title: '销售日期', dataIndex: 'saleDate', sorter: true }
      ];
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },

    chooseOrderNo() {
      this.visible = true;
    },
    closeDrawer(type) {
      if (type == 1) {
        this.$emit('close', false);
      } else {
        if (this.selectedRows) {
          this.$emit('save', this.selectedRows);
        }
      }
    }
  }
  // mounted() {
  //   this.BaseTable = this.$refs.listModal.$refs.pageTable;
  // }
};
</script>

<style lang="less" scoped></style>
